home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 41.zip
/
BS1 part 41
/
Abacus diskdrives IO.adf
/
CH5
/
typefile.c
< prev
next >
Wrap
C/C++ Source or Header
|
1978-06-28
|
4KB
|
127 lines
/*---------------------------------------------------------------------*/
/* Call of the DOS-Functions */
/* */
/* JEA, 18-08-87 */
/*---------------------------------------------------------------------*/
#include <exec/exec.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <libraries/filehandler.h>
#include <stdio.h>
char *error_strs[] = {
"ERROR_NO_DEFAULT_DIR: 201",
"ERROR_OBJECT_IN_USE: 202",
"ERROR_OBJECT_EXISTS: 203",
"ERROR_DIR_NOT_FOUND: 204",
"ERROR_OBJECT_NOT_FOUND: 205",
"ERROR_BAD_STREAM_NAME: 206",
"ERROR_OBJECT_TOO_LARGE: 207",
"ERROR_ACTION_NOT_KNOWN: 209",
"ERROR_INVALID_COMPONENT_NAME: 210",
"ERROR_INVALID_LOCK: 211",
"ERROR_OBJECT_WRONG_TYPE: 212",
"ERROR_DISK_NOT_VALIDATED: 213",
"ERROR_DISK_WRITE_PROTECTED: 214",
"ERROR_RENAME_ACROSS_DEVICES: 215",
"ERROR_DIRECTORY_NOT_EMPTY: 216",
"ERROR_TOO_MANY_LEVELS: 217",
"ERROR_DEVICE_NOT_MOUNTED: 218",
"ERROR_SEEK_ERROR: 219",
"ERROR_COMMENT_TOO_BIG: 220",
"ERROR_DISK_FULL: 221",
"ERROR_DELETE_PROTECTED: 222",
"ERROR_WRITE_PROTECTED: 223",
"ERROR_READ_PROTECTED: 224",
"ERROR_NOT_A_DOS_DISK: 225",
"ERROR_NO_DISK: 226"
};
/*---------------------------------------------------------------------*/
/* AmigaDOS Error-Text outpur */
/* */
/* */
/*---------------------------------------------------------------------*/
LONG
get_error()
{
LONG error;
error = IoErr();
if( error < 120 ){
switch( error ){
case 000:
printf( "All OK!\n" );
break;
case 103:
printf( "ERROR_NO_FREE_STORE: 103\n" );
break;
case 105:
printf( "ERROR_TASK_TABLE_FULL: 105\n" );
break;
case 120:
printf( "ERROR_LINE_TOO_LONG: 120\n" );
break;
case 121:
printf( "ERROR_FILE_NOT_OBJECT: 121\n" );
break;
case 122:
printf( "ERROR_INVALID_RESIDENT_LIBRARY: 122\n" );
break;
case 232:
printf( "ERROR_NO_MORE_ENTRIES: 232\n" );
break;
}
}
else{
printf( "%s\n", error_strs[error-201] );
}
return( error );
}
/*---------------------------------------------------------------------*/
/* Type */
/* */
/* */
/*---------------------------------------------------------------------*/
type( filename )
UBYTE *filename;
{
struct FileHandle *handle;
struct FileHandle *Open();
UBYTE buf;
LONG read_length;
handle = Open( filename, MODE_OLDFILE );
if( handle ){
do{
read_length = Read( handle, &buf, 1L );
printf( "%c", buf );
}
while( read_length );
Close( handle );
}
else{
get_error();
}
}
/*---------------------------------------------------------------------*/
/* Main program */
/* */
/* */
/*---------------------------------------------------------------------*/
main( arg_num, args )
int arg_num;
char *args[];
{
if( arg_num > 1 )
type( args[1] );
else
printf( "A file name is required!\n" );
}